RTC driver for XMC microcontroller family.
More...
|
| enum | XMC_RTC_DEBUG_MODE { XMC_RTC_RUN_IN_DEBUG_MODE = 0U,
XMC_RTC_STOP_IN_DEBUG_MODE = 1U
} |
| |
| enum | XMC_RTC_STATUS { XMC_RTC_STATUS_OK = 0U,
XMC_RTC_STATUS_ERROR = 1U,
XMC_RTC_STATUS_BUSY = 2U
} |
| |
| enum | XMC_RTC_EVENT {
XMC_RTC_EVENT_PERIODIC_SECONDS = RTC_MSKSR_MPSE_Msk,
XMC_RTC_EVENT_PERIODIC_MINUTES = RTC_MSKSR_MPMI_Msk,
XMC_RTC_EVENT_PERIODIC_HOURS = RTC_MSKSR_MPHO_Msk,
XMC_RTC_EVENT_PERIODIC_DAYS = RTC_MSKSR_MPDA_Msk,
XMC_RTC_EVENT_PERIODIC_MONTHS = RTC_MSKSR_MPMO_Msk,
XMC_RTC_EVENT_PERIODIC_YEARS = RTC_MSKSR_MPYE_Msk,
XMC_RTC_EVENT_ALARM = RTC_MSKSR_MAI_Msk
} |
| |
| enum | XMC_RTC_MONTH {
XMC_RTC_MONTH_JANUARY = 0U,
XMC_RTC_MONTH_FEBRUARY = 1U,
XMC_RTC_MONTH_MARCH = 2U,
XMC_RTC_MONTH_APRIL = 3U,
XMC_RTC_MONTH_MAY = 4U,
XMC_RTC_MONTH_JUNE = 5U,
XMC_RTC_MONTH_JULY = 6U,
XMC_RTC_MONTH_AUGUST = 7U,
XMC_RTC_MONTH_SEPTEMBER = 8U,
XMC_RTC_MONTH_OCTOBER = 9U,
XMC_RTC_MONTH_NOVEMBER = 10U,
XMC_RTC_MONTH_DECEMBER = 11U
} |
| |
| enum | XMC_RTC_WEEKDAY {
XMC_RTC_WEEKDAY_SUNDAY = 0U,
XMC_RTC_WEEKDAY_MONDAY = 1U,
XMC_RTC_WEEKDAY_TUESDAY = 2U,
XMC_RTC_WEEKDAY_WEDNESDAY = 3U,
XMC_RTC_WEEKDAY_THURSDAY = 4U,
XMC_RTC_WEEKDAY_FRIDAY = 5U,
XMC_RTC_WEEKDAY_SATURDAY = 6U
} |
| |
RTC driver for XMC microcontroller family.
Real-time clock (RTC) is a clock that keeps track of the current time. Precise real time keeping is with a 32.768 KHz external crystal clock or a 32.768 KHz high precision internal clock. It provides a periodic time based interrupt and a programmable alarm interrupt on time match. It also supports wakeup from hibernate.
The RTC low level driver provides functions to configure and initialize the RTC hardware peripheral.
◆ XMC_RTC_ALARM_t
Alarm time values of RTC
The structure presents a convenient way to set/obtain the alarm time values for seconds, minutes, hours, days, month and year of RTC. The XMC_RTC_SetAlarm() and XMC_RTC_GetAlarm() can be used to populate the structure with the alarm time value of RTC
◆ XMC_RTC_CONFIG_t
RTC initialization with time, alarm and clock divider(prescaler) configurations
The structure presents a convenient way to set/obtain the time and alarm configurations
for RTC. The XMC_RTC_Init() can be used to populate the structure with the time and alarm values of RTC.
◆ XMC_RTC_DEBUG_MODE_t
◆ XMC_RTC_EVENT_t
Events which enables interrupt request generation
◆ XMC_RTC_MONTH_t
Months used to program the date
◆ XMC_RTC_STATUS_t
Status return values for RTC low level driver
◆ XMC_RTC_TIME_t
Time values of RTC
The structure presents a convenient way to set/obtain the time values for seconds, minutes, hours, days, month and year of RTC. The XMC_RTC_SetTime() and XMC_RTC_GetTime() can be used to populate the structure with the time value of RTC
◆ XMC_RTC_WEEKDAY_t
Week days used program the date
◆ XMC_RTC_DEBUG_MODE
Debug mode status values
| Enumerator |
|---|
| XMC_RTC_RUN_IN_DEBUG_MODE | RTC is not stopped during halting mode debug
|
| XMC_RTC_STOP_IN_DEBUG_MODE | RTC is stopped during halting mode debug
|
Definition at line 69 of file xmc1_rtc.h.
◆ XMC_RTC_EVENT
Events which enables interrupt request generation
| Enumerator |
|---|
| XMC_RTC_EVENT_PERIODIC_SECONDS | Mask value to enable an event on periodic seconds
|
| XMC_RTC_EVENT_PERIODIC_MINUTES | Mask value to enable an event on periodic seconds
|
| XMC_RTC_EVENT_PERIODIC_HOURS | Mask value to enable an event on periodic seconds
|
| XMC_RTC_EVENT_PERIODIC_DAYS | Mask value to enable an event on periodic seconds
|
| XMC_RTC_EVENT_PERIODIC_MONTHS | Mask value to enable an event on periodic seconds
|
| XMC_RTC_EVENT_PERIODIC_YEARS | Mask value to enable an event on periodic seconds
|
| XMC_RTC_EVENT_ALARM | Mask value to enable an event on periodic seconds
|
Definition at line 110 of file xmc_rtc.h.
◆ XMC_RTC_MONTH
Months used to program the date
| Enumerator |
|---|
| XMC_RTC_MONTH_JANUARY | |
| XMC_RTC_MONTH_FEBRUARY | |
| XMC_RTC_MONTH_MARCH | |
| XMC_RTC_MONTH_APRIL | |
| XMC_RTC_MONTH_MAY | |
| XMC_RTC_MONTH_JUNE | |
| XMC_RTC_MONTH_JULY | |
| XMC_RTC_MONTH_AUGUST | |
| XMC_RTC_MONTH_SEPTEMBER | |
| XMC_RTC_MONTH_OCTOBER | |
| XMC_RTC_MONTH_NOVEMBER | |
| XMC_RTC_MONTH_DECEMBER | |
Definition at line 124 of file xmc_rtc.h.
◆ XMC_RTC_STATUS
Status return values for RTC low level driver
| Enumerator |
|---|
| XMC_RTC_STATUS_OK | Operation successful
|
| XMC_RTC_STATUS_ERROR | Operation unsuccessful
|
| XMC_RTC_STATUS_BUSY | Busy with a previous request
|
Definition at line 100 of file xmc_rtc.h.
◆ XMC_RTC_WEEKDAY
Week days used program the date
| Enumerator |
|---|
| XMC_RTC_WEEKDAY_SUNDAY | |
| XMC_RTC_WEEKDAY_MONDAY | |
| XMC_RTC_WEEKDAY_TUESDAY | |
| XMC_RTC_WEEKDAY_WEDNESDAY | |
| XMC_RTC_WEEKDAY_THURSDAY | |
| XMC_RTC_WEEKDAY_FRIDAY | |
| XMC_RTC_WEEKDAY_SATURDAY | |
Definition at line 143 of file xmc_rtc.h.
◆ XMC_RTC_ClearEvent()
| void XMC_RTC_ClearEvent |
( |
const uint32_t |
event | ) |
|
- Parameters
-
| event | A valid RTC event (XMC_RTC_EVENT_t) or a valid combination of logically OR'd events |
- Returns
- None
- Description:
- Clears periodic and alarm event(s) status
- The function sets the bitfields of CLRSR register to clear status bits in RAWSTAT and STSSR registers. Setting the value for the the RTC event(s) containing in the XMC_RTC_EVENT_t clears the corresponding status bits in RAWSTAT and STSSR registers.
- Related APIs:
- XMC_RTC_GetEventStatus()
Definition at line 147 of file xmc1_rtc.c.
◆ XMC_RTC_Disable()
| void XMC_RTC_Disable |
( |
void |
| ) |
|
- Returns
- None
- Description
- Disables RTC peripheral for programming its registers
- Related APIs:
- XMC_RTC_Enable(), XMC_SCU_RESET_AssertPeripheralReset()
Definition at line 113 of file xmc1_rtc.c.
◆ XMC_RTC_DisableEvent()
| void XMC_RTC_DisableEvent |
( |
const uint32_t |
event | ) |
|
- Parameters
-
| event | A valid RTC event (XMC_RTC_EVENT_t) or a valid combination of logically OR'd events |
- Returns
- None
- Description:
- Disable RTC periodic and alarm event(s)
- The function resets the bitfields of MSKSR register to disable interrupt generation for requested RTC event(s). Resetting the masking value for the the event(s) containing in the XMC_RTC_EVENT_t blocks the generation of the interrupt.
- Related APIs:
- XMC_RTC_EnableEvent()
Definition at line 139 of file xmc1_rtc.c.
◆ XMC_RTC_Enable()
| void XMC_RTC_Enable |
( |
void |
| ) |
|
- Returns
- None
- Description
- Enables RTC peripheral for programming its registers
- Related APIs:
- XMC_RTC_Disable(), XMC_SCU_RESET_DeassertPeripheralReset()
Definition at line 105 of file xmc1_rtc.c.
Referenced by XMC_RTC_Init().
◆ XMC_RTC_EnableEvent()
| void XMC_RTC_EnableEvent |
( |
const uint32_t |
event | ) |
|
- Parameters
-
| event | A valid RTC event (XMC_RTC_EVENT_t) or a valid combination of logically OR'd events |
- Returns
- None
- Description:
- Enable RTC periodic and alarm event(s)
- The function sets the bitfields of MSKSR register to enable interrupt generation for requested RTC event(s). Setting the masking value for the event(s) containing in the XMC_RTC_EVENT_t leads to a generation of the interrupt.
- Related APIs:
- XMC_RTC_DisableEvent()
Definition at line 131 of file xmc1_rtc.c.
◆ XMC_RTC_GetAlarm()
- Parameters
-
| alarm | Pointer to a constant XMC_RTC_ALARM_t structure containing the time parameters alarm seconds, alarm minutes, alarm hours, alarm days, alarm daysofweek, alarm month and alarm year.
|
- Returns
- None
- Description:
- Gets the RTC module alarm time value
- The function gets the alarm time values from ATIM0, ATIM1 registers. See the structure XMC_RTC_ALARM_t for the valid range of alarm time value parameters.
- Related APIs:
- XMC_RTC_SetAlarm()
Definition at line 249 of file xmc_rtc.c.
◆ XMC_RTC_GetAlarmStdFormat()
| void XMC_RTC_GetAlarmStdFormat |
( |
struct tm *const |
stdtime | ) |
|
- Parameters
-
| stdtime | Pointer to a constant ::tm structure containing the time parameters alarm seconds, alarm minutes, alarm hours, alarm days, alarm daysofweek, alarm month,
alarm year(since 1900) and alarm days in a year in standard format.
|
- Returns
- None
- Description:
- Gets the RTC module alarm time value in standard format
- The function gets the alarm time values from ATIM0, ATIM1 registers. See the structure XMC_RTC_ALARM_t for the valid range of alarm time value parameters.
For days the valid range is (1 - Actual days of month), year (since 1900) and daysinyear (0 -365).
- Related APIs:
- XMC_RTC_SetAlarm(), XMC_RTC_GetAlarm()
Definition at line 277 of file xmc_rtc.c.
◆ XMC_RTC_GetEventStatus()
| uint32_t XMC_RTC_GetEventStatus |
( |
void |
| ) |
|
- Returns
- None
- Description:
- Gets the RTC periodic and alarm event(s) status
- The function reads the bitfields of STSSR register to get the status of RTC events. Reading the value of the register STSSR gives the status of the event(s) containing in the XMC_RTC_EVENT_t.
- Related APIs:
- XMC_RTC_ClearEvent()
Definition at line 295 of file xmc_rtc.c.
◆ XMC_RTC_GetPrescaler()
- Returns
- None
- Description:
- Gets the RTC module prescaler value
- The function reads the CTR.DIV bitfield to get the prescalar value. The default value for the prescalar with the 32.768kHz crystal (or the internal clock) is 7FFFH for a time interval of 1 sec.
- Related APIs:
- XMC_RTC_SetPrescaler()
Definition at line 430 of file xmc_rtc.h.
◆ XMC_RTC_GetTime()
- Parameters
-
| time | Pointer to a constant XMC_RTC_TIME_t structure containing the time parameters seconds, minutes, hours, days, daysofweek, month and year. |
- Returns
- None
- Description:
- Gets the RTC module time value
- The function gets the time values from TIM0, TIM1 registers. See the structure XMC_RTC_TIME_t for the valid range of time value parameters.
- Related APIs:
- XMC_RTC_SetTime()
Definition at line 168 of file xmc_rtc.c.
◆ XMC_RTC_GetTimeStdFormat()
| void XMC_RTC_GetTimeStdFormat |
( |
struct tm *const |
stdtime | ) |
|
- Parameters
-
| stdtime | Pointer to a constant ::tm structure containing the time parameters seconds, minutes, hours, days, daysofweek, month, year(since 1900) and days in a
year in standard format.
|
- Returns
- None
- Description:
- Gets the RTC module time value in standard format
- The function gets the time values from TIM0, TIM1 registers. See the structure XMC_RTC_TIME_t for the valid range of time value parameters.
For days the valid range is (1 - Actual days of month), year (since 1900) and daysinyear (0 -365).
- Related APIs:
- XMC_RTC_SetTime(), XMC_RTC_GetTime()
Definition at line 196 of file xmc_rtc.c.
◆ XMC_RTC_Init()
RTC driver for XMC microcontroller family.
- Parameters
-
| config | Constant pointer to a constant XMC_RTC_CONFIG_t structure containing the time, alarm time and clock divider(prescaler) configuration. |
- Returns
- XMC_RTC_STATUS_t Always returns XMC_RTC_STATUS_OK (It contains only register assignment statements)
- Description:
- Initialize the RTC peripheral
Definition at line 74 of file xmc1_rtc.c.
◆ XMC_RTC_IsEnabled()
| bool XMC_RTC_IsEnabled |
( |
void |
| ) |
|
◆ XMC_RTC_IsRunning()
- Returns
- bool true if RTC is running false if RTC is not running
- Description:
- Checks the running status of the RTC
- The function reads the bitfield ENB of CTR register to get the running status of RTC.
- Related APIs:
- XMC_RTC_Start(), XMC_RTC_Stop()
Definition at line 666 of file xmc_rtc.h.
Referenced by XMC_RTC_Init().
◆ XMC_RTC_SetAlarm()
- Parameters
-
| alarm | Constant pointer to a constant XMC_RTC_ALARM_t structure containing the alarm time parameters alarm seconds, alarm minutes, alarm hours, alarm days, alarm daysofweek, alarm month and alarm year.
|
- Returns
- None
- Description:
- Sets the RTC module alarm time value
- The function sets the ATIM0, ATIM1 registers with alarm time values. See the structure XMC_RTC_ALARM_t for the valid range of alarm time value parameters.
- Related APIs:
- XMC_RTC_GetAlarm()
Definition at line 214 of file xmc_rtc.c.
Referenced by XMC_RTC_SetAlarmStdFormat().
◆ XMC_RTC_SetAlarmStdFormat()
| void XMC_RTC_SetAlarmStdFormat |
( |
const struct tm *const |
stdtime | ) |
|
- Parameters
-
| stdtime | Pointer to a ::tm structure containing the time parameters alarm seconds, alarm minutes, alarm hours, alarm days, alarm daysofweek, alarm month,
alarm year(since 1900) and alarm days in a year in standard format.
|
- Returns
- None
- Description:
- Sets the RTC module alarm time value in standard format
- The function sets the alarm time values from ATIM0, ATIM1 registers.
- Related APIs:
- XMC_RTC_SetAlarm(), XMC_RTC_GetAlarm()
Definition at line 259 of file xmc_rtc.c.
◆ XMC_RTC_SetDebugMode()
- Parameters
-
- Returns
- None
- Description:
- Configures the RTC into running or stopping mode during halting mode debug
- The function sets the CTR.SUS bitfield to configure the RTC into running or stopping mode during halting mode debug.
Definition at line 121 of file xmc1_rtc.c.
◆ XMC_RTC_SetPrescaler()
| void XMC_RTC_SetPrescaler |
( |
uint16_t |
prescaler | ) |
|
- Parameters
-
| prescaler | Prescaler value to be set
|
- Returns
- None
- Description:
- Sets the RTC module prescaler value
- The function sets the CTR.DIV bitfield to configure the prescalar value. The default value for the prescalar with the 32.768kHz crystal (or the internal clock) is 7FFFH for a time interval of 1 sec. Before setting the prescaler value RTC should be in stop mode and hibernate domain should be enabled.
- Related APIs:
- XMC_RTC_Stop(), XMC_RTC_Enable(), XMC_RTC_GetPrescaler()
Definition at line 117 of file xmc_rtc.c.
Referenced by XMC_RTC_Init().
◆ XMC_RTC_SetTime()
- Parameters
-
| timeval | Contstant pointer to a constant XMC_RTC_TIME_t structure containing the time parameters seconds, minutes, hours, days, daysofweek, month and year.
|
- Returns
- None
- Description:
- Sets the RTC module time values
- The function sets the TIM0, TIM1 registers with time values. The values can only be written when RTC is disabled. See the structure XMC_RTC_TIME_t for the valid range of time value parameters.
- Related APIs:
- XMC_RTC_GetTime(), XMC_RTC_Stop()
Definition at line 132 of file xmc_rtc.c.
Referenced by XMC_RTC_SetTimeStdFormat().
◆ XMC_RTC_SetTimeStdFormat()
| void XMC_RTC_SetTimeStdFormat |
( |
const struct tm *const |
stdtime | ) |
|
- Parameters
-
| stdtime | Pointer to a ::tm structure containing the time parameters seconds, minutes, hours, days, daysofweek, month, year(since 1900) and days in a
year in standard format.
|
- Returns
- None
- Description:
- Sets the RTC module time value in standard format
- The function sets the time values from TIM0, TIM1 registers.
- Related APIs:
- XMC_RTC_SetTime(), XMC_RTC_GetTime()
Definition at line 177 of file xmc_rtc.c.
◆ XMC_RTC_Start()
| void XMC_RTC_Start |
( |
void |
| ) |
|
- Returns
- None
- Description
- Enables RTC peripheral to start counting time
- The function starts the RTC for counting time by setting CTR.ENB bit. Before starting the RTC, it should not be in running mode and also hibernate domain should be enabled.
- Related APIs:
- XMC_RTC_Enable(), XMC_RTC_Stop(), XMC_SCU_RESET_DeassertPeripheralReset()
Definition at line 93 of file xmc_rtc.c.
◆ XMC_RTC_Stop()
| void XMC_RTC_Stop |
( |
void |
| ) |
|
- Returns
- None
- Description
- Disables RTC peripheral to start counting time
- The function stops the RTC for counting time by resetting CTR.ENB. Before stopping the RTC, hibernate domain should be enabled.
- Related APIs:
- XMC_RTC_Enable(), XMC_RTC_Start(), XMC_SCU_RESET_AssertPeripheralReset()
Definition at line 105 of file xmc_rtc.c.